package com.ssy.lingxi.system.controller;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.system.dto.request.*;
import com.ssy.lingxi.system.dto.response.MemberEquitiesSetDetailsResponse;
import com.ssy.lingxi.system.dto.response.MemberGradeDetailsResponse;
import com.ssy.lingxi.system.dto.response.MemberGradeListResponse;
import com.ssy.lingxi.system.service.MemberGradeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 会员设置-会员等级与权益设置
 * @author wrc
 * @date 2020/7/20
 */
@Api(tags = "会员等级与权益设置")
@RestController
public class MemberGradeController {


    @Autowired
    MemberGradeService memberGradeService;

    @ApiOperation(value = "会员等级与权益设置列表")
    @GetMapping("/member/grade/list")
    public Wrapper<PageData<MemberGradeListResponse>> memberGradeList(MemberGradeListRequest request) {
        return memberGradeService.memberGradeList(request);
    }


    @ApiOperation(value = "会员权益设置")
    @PostMapping("/member/equities/set")
    public Wrapper memberEquitiesSet(@RequestBody @Valid MemberEquitiesSetRequest request) {
        return memberGradeService.memberEquitiesSet(request);
    }


    @ApiOperation(value = "会员权益设置详情")
    @GetMapping("/member/equities/set")
    public Wrapper<List<MemberEquitiesSetDetailsResponse>> memberEquitiesSetDetails(@Valid MemberGradeDetailsRequest request) {
        return memberGradeService.memberEquitiesSetDetails(request);
    }


    @ApiOperation(value = "添加会员等级")
    @PostMapping("/member/grade/add")
    public Wrapper memberGradeAdd(@RequestBody @Valid MemberGradeAddRequest request, HttpServletRequest httpServletRequest) {
        return memberGradeService.memberGradeAdd(httpServletRequest,request);
    }



    @ApiOperation(value = "查询会员等级详情")
    @GetMapping("/member/grade/details")
    public Wrapper<MemberGradeDetailsResponse> memberGradeDetails(@Valid MemberGradeDetailsRequest request) {
        return memberGradeService.memberGradeDetails(request);
    }


    @ApiOperation(value = "修改会员等级")
    @PostMapping("/member/grade/update")
    public Wrapper memberGradeUpdate(@RequestBody @Valid MemberGradeUpdateRequest request) {
        return memberGradeService.memberGradeUpdate(request);
    }


    @ApiOperation(value = "删除会员等级")
    @PostMapping("/member/grade/delete")
    public Wrapper memberGradeDelete(@RequestBody @Valid MemberGradeDeleteRequest request) {
        return memberGradeService.memberGradeDelete(request);
    }


    @ApiOperation(value = "停用&启用会员等级")
    @PostMapping("/member/grade/update/state")
    public Wrapper memberGradeStop(@RequestBody @Valid MemberGradeDeleteRequest request) {
        return memberGradeService.memberGradeStop(request);
    }







}
